package cn.com.dycc.common.push_key.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.com.dycc.common.push_key.entity.UserChannel;
import cn.com.dycc.common.push_key.service.UserChannelService;
import cn.com.dycc.util.JsonResult;

@Controller
@RequestMapping("/channel")
public class UserChannelController {
	
	@Resource(name="userChannelService")
	private UserChannelService userChannelService;
	
	@RequestMapping("/bind.do")
	@ResponseBody
	public JsonResult bindChannel(HttpServletRequest reuqest,String channel_id){
		UserChannel userChannel = new UserChannel();
		String user_id = reuqest.getSession().getAttribute("id").toString();
		Integer deviceType = (Integer)reuqest.getSession().getAttribute("deviceType");
		userChannel.setUser_id(user_id);
		userChannel.setChannel_id(channel_id);
		userChannel.setDeviceType(deviceType);
		String mes = userChannelService.insertChannel(userChannel);
		return new JsonResult(mes);
		
	}
	
}
